//服务器入口文件
//创建koa的实例对象
const Koa = require("koa")
const app = new Koa()
//绑定中间件
//第一层中间件
const respDurationMiddleware = require("./middleware/koa_response_duration")
app.use(respDurationMiddleware)
//第二层中间件
const respHeaderMiddleware = require("./middleware/koa_response_header")
app.use(respHeaderMiddleware)
//第三层中间件
const respDataMiddleware = require("./middleware/koa_response_data")
app.use(respDataMiddleware)

app.listen(8888, () => {
    console.log("端口已启动");
})

const webSocketService = require("./service/web_socket_service");
//开启服务端的监听,监听客户端的连接
//连接成功后，会监听message事件的连接
webSocketService.listen();